/* eslint-disable @typescript-eslint/no-explicit-any */
/*
 *  Copyright 2021 Collate
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  http://www.apache.org/licenses/LICENSE-2.0
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

 /**
 * Create Messaging service entity request
 */
export interface CreateMessagingService {
    connection?: MessagingConnection;
    /**
     * Fully qualified name of the domain the Messaging Service belongs to.
     */
    dataAssetDir?: string;
    /**
     * List of fully qualified names of data products this entity is part of.
     */
    dataProducts?: string[];
    /**
     * Description of messaging service entity.
     */
    description?: string;
    /**
     * Display Name that identifies this messaging service. It could be title or label from the
     * source services.
     */
    displayName?: string;
    /**
     * Fully qualified name of the domain the Messaging Service belongs to.
     */
    domain?: string;
    /**
     * Name that identifies the this entity instance uniquely
     */
    name: string;
    /**
     * Owner of this messaging service.
     */
    owner?:      EntityReference;
    serviceType: MessagingServiceType;
    /**
     * Tags for this Messaging Service.
     */
    tags?: TagLabel[];
}

/**
 * Dashboard Connection.
 */
export interface MessagingConnection {
    config?: Connection;
}

/**
 * Kafka Connection Config
 *
 * Redpanda Connection Config
 *
 * Kinesis Connection Config
 *
 * Custom Messaging Service Connection to build a source that is not supported by
 * OpenMetadata yet.
 */
export interface Connection {
    /**
     * basic.auth.user.info schema registry config property, Client HTTP credentials in the form
     * of username:password.
     */
    basicAuthUserInfo?: string;
    /**
     * Kafka bootstrap servers. add them in comma separated values ex: host1:9092,host2:9092
     *
     * Redpanda bootstrap servers. add them in comma separated values ex: host1:9092,host2:9092
     */
    bootstrapServers?: string;
    /**
     * Confluent Kafka Consumer Config. From
     * https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
     *
     * Confluent Redpanda Consumer Config
     */
    consumerConfig?: { [key: string]: any };
    /**
     * sasl.mechanism Consumer Config property
     */
    saslMechanism?: SaslMechanismType;
    /**
     * sasl.password consumer config property
     */
    saslPassword?: string;
    /**
     * sasl.username consumer config property
     */
    saslUsername?: string;
    /**
     * Confluent Kafka Schema Registry Config. From
     * https://docs.confluent.io/5.5.1/clients/confluent-kafka-python/index.html#confluent_kafka.schema_registry.SchemaRegistryClient
     *
     * Confluent Redpanda Schema Registry Config.
     */
    schemaRegistryConfig?: { [key: string]: any };
    /**
     * Schema Registry SSL Config. Configuration for enabling SSL for the Schema Registry
     * connection.
     */
    schemaRegistrySSL?: Config;
    /**
     * Confluent Kafka Schema Registry URL.
     *
     * Confluent Redpanda Schema Registry URL.
     */
    schemaRegistryURL?: string;
    /**
     * security.protocol consumer config property
     */
    securityProtocol?:           SecurityProtocol;
    supportsMetadataExtraction?: boolean;
    /**
     * Service Type
     *
     * Custom messaging service type
     */
    type?:              MessagingServiceType;
    awsConfig?:         AWSCredentials;
    connectionOptions?: { [key: string]: string };
    /**
     * Source Python Class Name to instantiated by the ingestion workflow
     */
    sourcePythonClass?: string;
}

/**
 * AWS凭据配置
 */
export interface AWSCredentials {
    /**
     * 要假设的角色的Amazon资源名称（ARN），在假设角色的情况下，这是必需的字段
     */
    assumeRoleArn?: string;
    /**
     * 假定角色会话的标识符，在同一角色由不同主体或出于不同原因假定时，使用角色会话名称唯一标识会话，在假设角色的情况下，这是必需的字段
     */
    assumeRoleSessionName?: string;
    /**
     * 要假设的角色的Amazon资源名称（ARN），在假设角色的情况下，这是可选的字段
     */
    assumeRoleSourceIdentity?: string;
    /**
     * AWS访问密钥ID
     */
    awsAccessKeyId?: string;
    /**
     * AAWS区域
     */
    awsRegion: string;
    /**
     * AWS秘密访问密钥
     */
    awsSecretAccessKey?: string;
    /**
     * AWS会话令牌
     */
    awsSessionToken?: string;
    /**
     * AWS的终端点URL
     */
    endPointURL?: string;
    /**
     * 与boto会话一起使用的配置文件的名称
     */
    profileName?: string;
}

/**
 * sasl.mechanism Consumer Config property
 *
 * SASL Mechanism consumer config property
 */
export enum SaslMechanismType {
    Gssapi = "GSSAPI",
    Oauthbearer = "OAUTHBEARER",
    Plain = "PLAIN",
    ScramSHA256 = "SCRAM-SHA-256",
    ScramSHA512 = "SCRAM-SHA-512",
}

/**
 * Schema Registry SSL Config. Configuration for enabling SSL for the Schema Registry
 * connection.
 *
 * 客户端SSL配置
 *
 * OpenMetadata客户端配置以验证SSL证书
 */
export interface Config {
    /**
     * CA证书路径，例如，/path/to/public.cert。如果Verify SSL设置为`validate`，将使用该路径。
     */
    caCertificate?: string;
    /**
     * The SSL certificate used for client authentication.
     */
    sslCertificate?: string;
    /**
     * The private key associated with the SSL certificate.
     */
    sslKey?: string;
}

/**
 * security.protocol consumer config property
 */
export enum SecurityProtocol {
    Plaintext = "PLAINTEXT",
    SSL = "SSL",
    SaslPlaintext = "SASL_PLAINTEXT",
    SaslSSL = "SASL_SSL",
}

/**
 * Service Type
 *
 * Kafka service type
 *
 * Redpanda service type
 *
 * Service type.
 *
 * Custom messaging service type
 *
 * Type of messaging service - Kafka or Pulsar.
 */
export enum MessagingServiceType {
    CustomMessaging = "CustomMessaging",
    Kafka = "Kafka",
    Kinesis = "Kinesis",
    Redpanda = "Redpanda",
}

/**
 * Owner of this messaging service.
 *
 * This schema defines the EntityReference type used for referencing an entity.
 * EntityReference is used for capturing relationships from one entity to another. For
 * example, a table has an attribute called database of type EntityReference that captures
 * the relationship of a table `belongs to a` database.
 */
export interface EntityReference {
    /**
     * If true the entity referred to has been soft-deleted.
     */
    deleted?: boolean;
    /**
     * Optional description of entity.
     */
    description?: string;
    /**
     * Display Name that identifies this entity.
     */
    displayName?: string;
    /**
     * Fully qualified name of the entity instance. For entities such as tables, databases
     * fullyQualifiedName is returned in this field. For entities that don't have name hierarchy
     * such as `user` and `team` this will be same as the `name` field.
     */
    fullyQualifiedName?: string;
    /**
     * Link to the entity resource.
     */
    href?: string;
    /**
     * Unique identifier that identifies an entity instance.
     */
    id: string;
    /**
     * If true the relationship indicated by this entity reference is inherited from the parent
     * entity.
     */
    inherited?: boolean;
    /**
     * Name of the entity instance.
     */
    name?: string;
    /**
     * Entity type/class name - Examples: `database`, `table`, `metrics`, `databaseService`,
     * `dashboardService`...
     */
    type: string;
}

/**
 * 此模式定义了用于使用标签标记实体的标签类型
 */
export interface TagLabel {
    /**
     * 标签标签的描述
     */
    description?: string;
    /**
     * 标识此标签的显示名称
     */
    displayName?: string;
    /**
     * 到标签资源的链接
     */
    href?: string;
    /**
     *
     * 标签类型描述标签标签是如何应用的，'Manual'表示标签标签是由人员应用的。'Derived'表示使用关联的标签关系导出了标签标签（有关详细信息，请参见Classification.json）。'Propagated`表示标签标签是根据血统从上游传播的。'Automated'在使用工具确定标签标签时使用。
     */
    labelType: LabelType;
    /**
     * 标签或词汇术语的名称
     */
    name?: string;
    /**
     * 标签来自标签还是词汇表
     */
    source: TagSource;
    /**
     * 'Suggested'状态在用户或工具建议标签标签时使用。实体的所有者必须在将其标记为'Confirmed'之前确认建议的标签
     */
    state:  State;
    style?: Style;
    tagFQN: string;
}

/**
 *
 * 标签类型描述标签标签是如何应用的，'Manual'表示标签标签是由人员应用的。'Derived'表示使用关联的标签关系导出了标签标签（有关详细信息，请参见Classification.json）。'Propagated`表示标签标签是根据血统从上游传播的。'Automated'在使用工具确定标签标签时使用。
 */
export enum LabelType {
    Automated = "Automated",
    Derived = "Derived",
    Manual = "Manual",
    Propagated = "Propagated",
}

/**
 * 标签来自标签还是词汇表
 */
export enum TagSource {
    Classification = "Classification",
    Glossary = "Glossary",
}

/**
 * 'Suggested'状态在用户或工具建议标签标签时使用。实体的所有者必须在将其标记为'Confirmed'之前确认建议的标签
 */
export enum State {
    Confirmed = "Confirmed",
    Suggested = "Suggested",
}

/**
 * UI Style is used to associate a color code and/or icon to entity to customize the look of
 * that entity in UI.
 */
export interface Style {
    /**
     * Hex Color Code to mark an entity such as GlossaryTerm, Tag, Domain or Data Product.
     */
    color?: string;
    /**
     * An icon to associate with GlossaryTerm, Tag, Domain or Data Product.
     */
    iconURL?: string;
}
